#include <stdio.h>
#include <stdlib.h>

struct Node {
    int data;
    struct Node* next;
};

struct Node* head = NULL;
struct Node* tail = NULL;

int main() {
    int inp[100100], len = 0;
    while (scanf("%d", &inp[++len]) != EOF);
    len--;
    int n = inp[len--], m = inp[len--];

    for (int i = 1; i <= m - 1; i++) printf("%d ", inp[i]);
    for (int i = n; i >= m; i--) printf("%d ", inp[i]);
    for (int i = n + 1; i <= len; i++) printf("%d ", inp[i]);
    for (int i=1;i<=len;i++) printf("%d ", inp[i]);
    return 0;
}
